For a better view of the help docment, please download and read the README.html
Prescan Simcpp Generator aims to provide a auto-generator for Prescan SimCPP project so that user can easily generate the C++ codes, build and run the simulation. Now, the following parts are supported for generation:
This project is not officially released by Siemens Prescan, which is only for user learning and reference.
NOTE, for any issues you meet with when using this generator, please firstly contact the Prescan support engineer or you can submit your issue on Siemens Support Center. Please DON'T send any emails to Prescan official Support Team directly, otherwise you won't have any response to your question.
Before you start with this project, make sure you've installed the following softwares:
According to installation of Prescan on your machine, you may need to do the following configurations:
set_env.bat,add the Prescan path Prescan_path as well as Plugins path;PATH, if you don't have all plugins installed on your system, please comment out thoese not installed plugins in the bat file.Prescan_DIR;PATH. If you have python in system path, please ignore and delete this step.PYTHONPATH, which you can find in Prescan installation folder;experiment_dir;experiment_pb;simcpp_dir is the destination foler where you want to put the generated simcpp project. Typically, you can set it to a 'simcpp' folder in the %experiment_dir%. So set it to "%experiment_dir%\\simcpp"Finally it looks like this:
@ECHO OFF
setlocal
set "Prescan_path=D:\Simcenter Prescan\Prescan_2307"
set "Prescan_plugin_path=D:\Simcenter Prescan\Prescan_2307\Plugins"
:::: add Prescan modules and plugin dependency path(please comment out(::) these plugins which are not installed on your machine)
set "PATH=%PATH%;%Prescan_path%\bin;%"
set "PATH=%PATH%;%Prescan_plugin_path%\FullWaveformLidarPlugin\bin;"
set "PATH=%PATH%;%Prescan_plugin_path%\PBRadarPlugin\bin;"
set "PATH=%PATH%;%Prescan_plugin_path%\PointCloudLidarPlugin\bin;"
set "PATH=%PATH%;%Prescan_plugin_path%\ProbabilisticSensorsPlugin\bin;"
set "PATH=%PATH%;%Prescan_plugin_path%\PhysicsBasedCameraUnreal;"
set "PATH=%PATH%;%Prescan_plugin_path%\V2XPlugin\bin;"
:::: add cmake config path
set "Prescan_DIR=%Prescan_path%\lib\cmake"
:::: if you have python in system, please ignor and delete it
set "PATH=D:\Python38\Scripts\;D:\Python38\;%PATH%"
:::: add Prescan python API path
set "PYTHONPATH=%PYTHONPATH%;%Prescan_path%\python;"
set "PYTHONPATH=%PYTHONPATH%;%Prescan_path%\modules;"
set "PYTHONPATH=%PYTHONPATH%;%Prescan_plugin_path%;"
:: add current Prescan experiment and destination simcpp project path
set "experiment_dir=E:\Siemens\1_Prescan\3_Experiments\33_SimcppGenerator\PrescanSimcppGenerator\prescandemos\SimcppGenerator"
set "experiment_pb=E:\Siemens\1_Prescan\3_Experiments\33_SimcppGenerator\PrescanSimcppGenerator\prescandemos\SimcppGenerator\SimcppGenerator.pb"
set "simcpp_dir=E:\Siemens\1_Prescan\3_Experiments\33_SimcppGenerator\PrescanSimcppGenerator\prescandemos\SimcppGenerator\simcpp"
echo "set path ..."
cmd
NOTE:Prescan 2307 or higher offcially supports Ubuntu 20.04 and has almost all the features that it has on Windows except V2X plugin. For the previous version(<2307), Prescan doesn't support Physics-Based Point Cloud Lidar and Physics-Based Radar on Ubuntu 20.04. User may need to add plugin path to environment vars according to the Prescan installation on your own Ubuntu machine.
It is recommended to install plugins on ubuntu in the same folder as windows, that is, to put all plugins in a Plugins folder in Prescan installation path and rename the plugins as what it's named on windows as shown follows:
With regard to how to install and enable Prescan Plugin on ubuntu,please refer to Prescan help manual.
#! /usr/bin/env bash
export Prescan_path=/usr/local/Prescan_2307
export Prescan_plugin_path=/usr/local/Prescan_2307/Plugins
### add Prescan Plugin dependency path(please delete these not installed on your machine)
export PATH=$PATH:$Prescan_path/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_path/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/FullWaveformLidarPlugin/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/PBRadarPlugin/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/PointCloudLidarPlugin/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/ProbabilisticSensorsPlugin/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/PhysicsBasedCameraUnreal
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/V2X/(not supported on linux)
### add cmake config path
export Prescan_DIR=$Prescan_path/lib/cmake
### add Prescan python API path
export PYTHONPATH=$PYTHONPATH:$Prescan_path/python
export PYTHONPATH=$PYTHONPATH:$Prescan_path/modules
export PYTHONPATH=$PYTHONPATH:$Prescan_plugin_path
### add current Prescan experiment and destination simcpp project path
export experiment_dir=/home/yang/Desktop/PrescanSimcppGenerator/prescandemos/SimcppGenerator
export experiment_pb=/home/yang/Desktop/PrescanSimcppGenerator/prescandemos/SimcppGenerator/SimcppGenerator.pb
export simcpp_dir=/home/yang/Desktop/PrescanSimcppGenerator/prescandemos/SimcppGenerator/simcpp
echo "set path ..."
For users who have installed Prescan with all features enabled, you can directly use this generator. However, if some plugins are disabled, you may need to do some modifications to the generator source codes before you can use it correctly. If you have all features enabled, you will find a Plugins folder in Prescan installation path, as shown in following picture. These highlighted plugins have some open API to users.
If you don't have all plugins installed on your system, you need to modify some source codes in the generator so that the generator can work correctly. You can either do this automatically or manually.
To modify the generator codes automatically, you must make sure the set_env.bat/set_env.bash files are correctly configured. Particularly, the library and dependency paths should be correct. For exampple, if you don't have FullWaveformLidarPlugin and PointCloudLidarPlugin then you should comment them out in the set_env files.
:::: add Prescan modules and plugin dependency path(please comment out(::) these plugins which are not installed on your machine)
set "PATH=%PATH%;%Prescan_path%\bin;%"
::set "PATH=%PATH%;%Prescan_plugin_path%\FullWaveformLidarPlugin\bin;"
set "PATH=%PATH%;%Prescan_plugin_path%\PBRadarPlugin\bin;"
::set "PATH=%PATH%;%Prescan_plugin_path%\PointCloudLidarPlugin\bin;"
set "PATH=%PATH%;%Prescan_plugin_path%\ProbabilisticSensorsPlugin\bin;"
set "PATH=%PATH%;%Prescan_plugin_path%\PhysicsBasedCameraUnreal;"
set "PATH=%PATH%;%Prescan_plugin_path%\V2XPlugin\bin;"
### add Prescan modules and plugin dependency path(please comment out(::) these plugins which are not installed on your machine)
export PATH=$PATH:$Prescan_path/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_path/lib
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/FullWaveformLidarPlugin/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/PBRadarPlugin/bin
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/PointCloudLidarPlugin/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/ProbabilisticSensorsPlugin/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/PhysicsBasedCameraUnreal
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Prescan_plugin_path/V2X/(not supported on linux)
when you correctly configure the set_env files. Then you can go to Code Generation. When you run the main.py, you just need to specify the option argv -conf_api 1. Then the generator codes will be automatically modified according your set_env files.
To manually modify the source codes of the generaor, you need to modify two parts:
prescan_python_dmapi.py.sensors and generators folders.Firstly, you need to delete/commentout some codes in ./rename_api_namespace/prescan_python_dmapi.py. This python module will import the open API of all Prescan features.
import prescan.api
import prescan.api.experiment
import prescan.api.types
import prescan.api.log
import prescan.genericmodel
import prescan.internal
import prescan.assets
import prescan.assets.bufferdata
import prescan.api.air
import prescan.api.alms
import prescan.api.annotations
import prescan.api.brs
import prescan.api.camera
import prescan.api.depthcamera
import prescan.api.iss
import prescan.api.collisiondetection
import prescan.api.communication
import prescan.api.roads
import prescan.api.lidar
import prescan.api.lms
import prescan.api.objectlistprovider
import prescan.api.ocs
import prescan.api.opendrive
import prescan.api.openscenario
import prescan.api.pcs
import prescan.api.physicsbasedcameraunreal
import prescan.api.viewer
import prescan.api.radar
import prescan.api.tis
import prescan.api.trafficsignalsensor
import prescan.api.scenario
import prescan.api.trajectory
import prescan.api.ultrasonic
import prescan.api.userdata
import prescan.api.vehicledynamics
import prescan.internal.algorithm
import prescan.internal.scenario
import prescan.api.fullwaveformlidar
import prescan.api.pbradar
import prescan.api.pointcloudlidar
import prescan.api.probabilisticcamera
import prescan.api.probabilisticradar
import prescan.api.v2x
import prescan.api.roads.types
import prescan.api as prescan_api
import prescan.api.experiment as prescan_api_experiment
import prescan.api.types as prescan_api_types
import prescan.api.log as prescan_api_log
import prescan.genericmodel as prescan_genericmodel
import prescan.internal as prescan_internal
import prescan.assets as prescan_assets
import prescan.assets.bufferdata as prescan_assets_bufferdata
import AIR.python_interface.prescan.api.air as prescan_api_air
import ALMS.python_interface.prescan.api.alms as prescan_api_alms
import Annotations.python_interface.prescan.api.annotations as prescan_api_annotations
import BRS.python_interface.prescan.api.brs as prescan_api_brs
import Camera.python_interface.prescan.api.camera as prescan_api_camera
import Camera.python_interface.prescan.api.depthcamera as prescan_api_depthcamera
import Camera.python_interface.prescan.api.iss as prescan_api_iss
import CollisionDetection.python_interface.prescan.api.collisiondetection as prescan_api_collisiondetection
import Communication.python_interface.prescan.api.communication as prescan_api_communication
import GraphBasedRoads.python_interface.prescan.api.roads as prescan_api_roads
import Lidar.python_interface.prescan.api.lidar as prescan_api_lidar
import LMS.python_interface.prescan.api.lms as prescan_api_lms
import ObjectListProvider.python_interface.prescan.api.objectlistprovider as prescan_api_objectlistprovider
import OCS.python_interface.prescan.api.ocs as prescan_api_ocs
import OpenDriveImporter.python_interface.prescan.api.opendrive as prescan_api_opendrive
import OpenScenarioImporter.python_interface.prescan.api.openscenario as prescan_api_openscenario
import PCS.python_interface.prescan.api.pcs as prescan_api_pcs
import PhysicsBasedCamera.python_interface.prescan.api.physicsbasedcameraunreal as prescan_api_physicsbasedcameraunreal
import PrescanViewer.python_interface.prescan.api.viewer as prescan_api_viewer
import Radar.python_interface.prescan.api.radar as prescan_api_radar
import TIS.python_interface.prescan.api.tis as prescan_api_tis
import TrafficSignalSensor.python_interface.prescan.api.trafficsignalsensor as prescan_api_trafficsignalsensor
import Trajectory.python_interface.prescan.api.scenario as prescan_api_scenario
import Trajectory.python_interface.prescan.api.trajectory as prescan_api_trajectory
import UltraSonic.python_interface.prescan.api.ultrasonic as prescan_api_ultrasonic
import UserData.python_interface.prescan.api.userdata as prescan_api_userdata
import VehicleDynamics.python_interface.prescan.api.vehicledynamics as prescan_api_vehicledynamics
import Algorithm.python_interface.prescan.internal.algorithm as prescan_internal_algorithm
import Trajectory.python_interface.prescan.internal.scenario as prescan_internal_scenario
import FullWaveformLidarPlugin.modules.fullwaveformlidar.python_interface.prescan.api.fullwaveformlidar as prescan_api_fullwaveformlidar
import PBRadarPlugin.modules.pbradar.python_interface.prescan.api.pbradar as prescan_api_pbradar
import PointCloudLidarPlugin.modules.pointcloudlidar.python_interface.prescan.api.pointcloudlidar as prescan_api_pointcloudlidar
import ProbabilisticSensorsPlugin.modules.ProbabilisticCamera.python_interface.prescan.api.probabilisticcamera as prescan_api_probabilisticcamera
import ProbabilisticSensorsPlugin.modules.ProbabilisticRadar.python_interface.prescan.api.probabilisticradar as prescan_api_probabilisticradar
import V2XPlugin.modules.v2x.python_interface.prescan.api.v2x as prescan_api_v2x
import GraphBasedRoads.python_interface.prescan.api.roads.types as prescan_api_roads_types
However, some users may not be able to access to all Prescan features. Then, user need to delete/commentout these API that you don't have access to. For example, if you don't have license for Physics-Based sensors, you need to delete the imported API for them. The following lists which API you need to delete or commentout if you don't have access to it.
if no access to v2x, delete/commmentout:
#import prescan.api.v2x
#import V2XPlugin.modules.v2x.python_interface.prescan.api.v2x as prescan_api_v2x
if no access to physicsbasedcameraunreal, delete/commmentout:
#import prescan.api.physicsbasedcameraunreal
#import PhysicsBasedCamera.python_interface.prescan.api.physicsbasedcameraunreal as prescan_api_physicsbasedcameraunreal
if no access to fullwaveformlidar, delete/commmentout:
#import prescan.api.fullwaveformlidar
#import FullWaveformLidarPlugin.modules.fullwaveformlidar.python_interface.prescan.api.fullwaveformlidar as prescan_api_fullwaveformlidar
if no access to pbradar, delete/commmentout:
#import prescan.api.pbradar
#import PBRadarPlugin.modules.pbradar.python_interface.prescan.api.pbradar as prescan_api_pbradar
if no access to pointcloudlidar, delete/commmentout:
#import prescan.api.pointcloudlidar
#import PointCloudLidarPlugin.modules.pointcloudlidar.python_interface.prescan.api.pointcloudlidar as prescan_api_pointcloudlidar
if no access to probabilisticcamera/radar, delete/commmentout:
#import prescan.api.probabilisticcamera
#import prescan.api.probabilisticradar
#import ProbabilisticSensorsPlugin.modules.ProbabilisticCamera.python_interface.prescan.api.probabilisticcamera as prescan_api_probabilisticcamera
#import ProbabilisticSensorsPlugin.modules.ProbabilisticRadar.python_interface.prescan.api.probabilisticradar as prescan_api_probabilisticradar
If you don't even find the Plugins folder in your Prescan installation path, you need to delete/commentput all above. In addition, Prescan doesn't support v2x on Linux. So you must delete/commentout v2x API import when you use the generator on Linux.
After you finish the delete/commentout of API import, you should continue to delete the relevant modules in sensors and generator folders. For example, if you delete/commentout the API import of pointcloudlidar in prescan_python_dmapi.py, then you must delete Pointcloudlidar.py and PointcloudlidarGenerator.py in sensors and generator folders, respectively.
Before you start to generate simcpp codes, please follow the guide to delete/comment source codes according to the installation of Prescan features on your machine.
SimCPP Generator can help generate the Prescan simcpp codes on both Windows and Ubuntu. Considering the flexibilty of Prescan Plugin installation on Ubuntu, plugin folders may have different path and names。Hence, it is recommended that you generate codes on windows and copy them to Ubuntu if you want to use some plugin features.
First create or open a Prescan experiment. In this project, we have a demo experiment in ./prescandemosfolder, called SimcppGenerator.
In the Prescan GUI, you can create scenario, roads and actors,then set the simulation conditions, add trajectory or AmesimPreconfigedDynamics to actors,and finally add sensors to actors(supported sensors for auto generation);
Modify the vars in set_env.bat,e.g., when this project locates in E:\Siemens\1_Prescan\3_Experiments\33_SimcppGenerator\PrescanSimcppGenerator, the following paths are Prescan experiment, pb file and simcpp:
set "experiment_dir=E:\Siemens\1_Prescan\3_Experiments\33_SimcppGenerator\PrescanSimcppGenerator\prescandemos\SimcppGenerator"
set "experiment_pb=E:\Siemens\1_Prescan\3_Experiments\33_SimcppGenerator\PrescanSimcppGenerator\prescandemos\SimcppGenerator\SimcppGenerator.pb"
set "simcpp_dir=E:\Siemens\1_Prescan\3_Experiments\33_SimcppGenerator\PrescanSimcppGenerator\prescandemos\SimcppGenerator\simcpp"
Double click set_env.bat and a cmd Terminal will pop-up,type:
python main.py -pb_dir %experiment_pb% -out_dir %simcpp_dir%
if you want to automatically modify the generator source codes according to the set_env file, you may need to run:
python main.py -pb_dir %experiment_pb% -out_dir %simcpp_dir% -conf_api 1
where, the first arguement -pb_dir is the path to pb file and the second optional argument -out_dir is where you want to put the generated simcpp codes, here we put it in %simcpp_dir%. If %simcpp_dir% already exists,then there will be a warning and you need to confirm as shown in the following picture:
input 'y' means to delete the existing simcpp folder and input 'n' or others mean to exit the program without doing anything. If codes are generated successfully, you will see the following outputs:
Go to the Prescan experiment folder, you can see a folder called 'simcpp' which includes all the C++ codes for this experiment simulation.
Inside the folder,you can see the file strcture:
double click set_env.bat will pop up a cmd termina, type:
build.bat
if build successfully,you will see the following outputs:
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.22621.
-- The CXX compiler identification is MSVC 19.20.27508.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: c:/apps/MVS16/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Prescan 2023.1.0 at D:/Simcenter Prescan/Prescan_2302/lib/cmake
Plugins found:
- Prescan::FullWaveformLidar
- Prescan::PBRadar
- Prescan::PointCloudLidar
- Prescan::ProbabilisticSensors
- Prescan::v2x
-- Generating helper scripts for demo: SimCppProject
-- Experiment directory set to: C:/Users/yiyan5ez/Desktop/SimcppGenerator
-- PrescanRootDIR D:/Simcenter Prescan/Prescan_2302
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/yiyan5ez/Desktop/SimcppGenerator/simcpp/build
Microsoft (R) Build Engine version 16.0.462+g62fb89029d for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Checking File Globs
Checking Build System
Building Custom Rule C:/Users/yiyan5ez/Desktop/SimcppGenerator/simcpp/CMakeLists.txt
main.cpp
cnpy.cpp
Generating Code...
SimCppProject.vcxproj -> C:\Users\yiyan5ez\Desktop\SimcppGenerator\simcpp\build\Release\SimCppProject.exe
Building Custom Rule C:/Users/yiyan5ez/Desktop/SimcppGenerator/simcpp/CMakeLists.txt
then double click set_env.bat to pop up another cmd window,type:
run.bat
Prescan will start the simulation:
if you want to change the simulation duration,openrun.bat:
prescanrun %simcpp_dir%\\build\\Release\\SimCppProject.exe %experiment_pb% 10
where,number 10 means simulation duration of 10 seconds.
Same as on Windows;
Same as on Windows;
Copy the Simcpp Generator project to Ubuntu;
Modify the vars in set_env.bash according to your experiment path:
export experiment_dir=/home/yang/Desktop/PrescanSimcppGenerator/prescandemos/SimcppGenerator
export experiment_pb=/home/yang/Desktop/PrescanSimcppGenerator/prescandemos/SimcppGenerator/SimcppGenerator.pb
export simcpp_dir=/home/yang/Desktop/PrescanSimcppGenerator/prescandemos/SimcppGenerator/simcpp
Open a terminal from current SimCPP generator project folder,and type step by step:
source set_env.bash
python3 main.py -pb_dir $experiment_pb -out_dir $simcpp_dir
if successful, you will find the 'simcpp' folder in your Prescan experiment.
Open a terminal from simcpp folder,and type in sequence:
source set_env.bash
bash build.bash
if build successfully, you will the following outputs:
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Prescan 2023.1.0 at /usr/local/Prescan_2302/lib/cmake
Plugins found: <NONE>
-- Generating helper scripts for demo: SimCppProject
-- Experiment directory set to: /home/yang/Desktop/SimcppGenerator
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yang/Desktop/SimcppGenerator/simcpp/build
[ 33%] Building CXX object CMakeFiles/SimCppProject.dir/simmodel/main.cpp.o
In file included from /home/yang/Desktop/SimcppGenerator/simcpp/simmodel/simmodel/simmodel.h:21,
from /home/yang/Desktop/SimcppGenerator/simcpp/simmodel/main.cpp:23:
/home/yang/Desktop/SimcppGenerator/simcpp/simmodel/utils/threadpool.h: In function ‘double prescan::utils::get_timestamp()’:
/home/yang/Desktop/SimcppGenerator/simcpp/simmodel/utils/threadpool.h:56:8: warning: ‘int ftime(timeb*)’ is deprecated: Use gettimeofday or clock_gettime instead [-Wdeprecated-declarations]
56 | ftime(&now);
| ~~~~~^~~~~~
In file included from /home/yang/Desktop/SimcppGenerator/simcpp/simmodel/utils/threadpool.h:38,
from /home/yang/Desktop/SimcppGenerator/simcpp/simmodel/simmodel/simmodel.h:21,
from /home/yang/Desktop/SimcppGenerator/simcpp/simmodel/main.cpp:23:
/usr/include/x86_64-linux-gnu/sys/timeb.h:29:12: note: declared here
29 | extern int ftime (struct timeb *__timebuf)
| ^~~~~
[ 66%] Building CXX object CMakeFiles/SimCppProject.dir/simmodel/utils/cnpy.cpp.o
[100%] Linking CXX executable SimCppProject
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libplatform.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libpimp.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libfederate_sdk.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libpssettings.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libmoduleloader.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libprtl.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libvislibrary.so has a program header with invalid alignment
[100%] Built target SimCppProject
then, continue with run.bash to execute the simulation. Please make sure Prescan DeploymentService is already runnning。So, just open a terminal from simcpp and type:
source set_env.bash
bash run.bash
the simulation is running as follows:
Please see online/offline trainings
This project contains a demo which shows how to communicate between simcpp and a user application(C++ or Python) through shared memory on the same PC. This demo is tested on Windows11和Ubuntu22.04. The workflow is as follows:
First of all, user needs to define the intermidiate message types using protobuf formate and compile them to C++ and Python files. The messages work as a bridge medium between Prescan sensors types and what the user needs.。A complete simulation cycle between Simcpp and user App includes the following three steps:
First of all, you should install all the prerequisites for SimCpp Generator. Then, you should continue to install the following dependencies:
Inside ./bridgedemos folder, copy simcpp to ./prescandemos/SimcppGenerator experiment.
Inside ./prescandemos/SimcppGenerator/simcpp folder, follow Environment Vars to modify set_env.bat, where vcpkg is "%vcpkg installation folder%\scripts\buildsystems\vcpkg.cmake, which is used to find boost and protobuf in CMake.
Then, double click set_env.bat and type the following command in the pop-up cmd window:
build.bat
if built successfully, you will see the following outputs:
...
Generating Code...
SimCppProject.vcxproj -> C:\Users\yiyan5ez\Desktop\PrescanSimcppGenerator\prescandemos\SimcppGenerator\simcpp\build\R
elease\SimCppProject.exe
Building Custom Rule C:/Users/yiyan5ez/Desktop/PrescanSimcppGenerator/prescandemos/SimcppGenerator/simcpp/CMakeLists.txt
double click set_env.bat and type the following in the pop-up cmd windows:
run.bat
Please remember to start Prescan Process Manager before you run this command. If succeed, you will see the following. Note, the simcpp will get blocked cause the user App is not running.
Then build user C++ App. Inside ./bridgedemos/cppbridge folder and modify vcpkg in set_env.bat. Double click set_env.bat, type the following command in the pop-up cmd window:
build.bat
if built successfully, you will see the following outputs:
...
cppbridge.vcxproj -> C:\Users\yiyan5ez\Desktop\PrescanSimcppGenerator\bridgedemos\cppbridge\build\Release\cppbridge.exe
Building Custom Rule C:/Users/yiyan5ez/Desktop/PrescanSimcppGenerator/bridgedemos/cppbridge/CMakeLists.txt
finally, continue to type the following command in the cmd window:
run.bat
if successful, the simulation will be running and you will see changes in Prescan Viewer.
When simulation ends, Simcpp and user C++ App will finish automatically. On Windows, please start Simcpp first and then user C++ App.
The same as step1 in Windows(Simcpp and C++ user App).
The same as step2 in Windows(Simcpp and C++ user App).
The same as step3 in Windows(Simcpp and C++ user App).
The same as step4 in Windows(Simcpp and C++ user App).
When Simcpp is running, inside C:\ProgramData\boost_interprocess folder, find the folder which contains the following files:
inside ./bridgedemos/pybridge/shmtypes folder,open and edit bridge_shm..py, change the folder name(in the example, it's 44000000), save and close:
class ShmHandler:
if platform.system() == "Windows":
shm_path = "C:\\ProgramData\\boost_interprocess\\44000000\\"
elif platform.system() == "Linux":
shm_path = "/dev/shm/"
else:
raise Exception("Platform not supported")
back to ./bridgedemos/pybridge folder, and open a Terminal and types:
python main.py
you will see the following if succeed:
When simulation ends, Simcpp and user Python App will finish automatically. On Windows, please start Simcpp first and then user Python App.
The same as step1 in Windows(Simcpp and C++ user App).
Inside ./prescandemos/SimcppGenerator/simcpp folder,followEnvironment Vars to modify set_env.bash.
Then open a Terminal from current path and type:
source set_env.bash
bash build.bash
you will see followings outputs if succeed:
...
[100%] Linking CXX executable SimCppProject
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libplatform.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libpimp.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libfederate_sdk.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libpssettings.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libmoduleloader.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libprtl.so has a program header with invalid alignment
/usr/bin/ld: warning: /usr/local/Prescan_2302/lib/libvislibrary.so has a program header with invalid alignment
[100%] Built target SimCppProject
Open Terminal from current path and type:
source set_env.bash
bash run.bash
Please make sure DeploymentService is running before you run the commands. Note, the simcpp will get blocked cause the user App is not running.
Then build the user Python App. Inside ./bridgedemos/cppbridge folder. Start a terminal from current path and type:
bash build.bash
if succeed, you will see:
...
[100%] Linking CXX executable cppbridge
[100%] Built target cppbridge
finally, continue to type:
bash run.bash
the simulation will be runnning and you can see the changes in Prescan Viewer:
When simulation ends, Simcpp and user Python App will finish automatically. On Ubuntu, we don't specify the order to run Simcpp and user C++ App
./bridgedemos/pybridge folder, open a terminal and type:python3 main.py
you will see following if succeed:C:\ProgramData\boost_interprocess are not named by the user given sharedmemory names. So, python can't map to relevant memory.'federate_record=1' is enabled, the maximun number of objects with active trajectory is limited to a certain threshold, not sure how much exactly, but tested on windows it maybe 500 while 1000 on Linux(not sure). Over thses values may raise simulation runtime error and crash.'federate_record=1' is enabled, it is recommended to initial all movable objects' states in the initial function, otherwise replay may cause some jump movements in the viewer.